package com.fc.advbox.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.fc.advbox.common.ResponseJson;
import com.fc.advbox.controller.admin.BaseController;
import com.fc.advbox.entity.EquipmentMaintainEntity;
import com.fc.advbox.service.IOrgAcctService;
import com.fc.advbox.utils.RRException;
import com.fc.advbox.utils.validator.ValidatorUtils;
import com.fc.advbox.utils.validator.group.AddGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by E7450 on 2018/7/18.
 */
@RestController
@RequestMapping("/api/organization/account")
@Api(value="组织账号接口", tags={"组织账号接口"})
public class OrgAccountController extends BaseController {

    @Autowired
    private IOrgAcctService orgAcctService;

    @ApiOperation(value = "POST -- 组织账号提现",
            notes = " REST 方式请求" +
                    "Request Body: <ul>" +
                    "<li><i>必填：orgId: 组织ID</i></li>" +
                    "<li><i>必填：amount:提现金额, 整数或小数，小数点后最多两位</i></li>" +
                    "<li><i>可选：comment: 备注</i></li>" +
                    "</ul>")
    @PostMapping("/intoCash")
    public ResponseJson doSave(@RequestBody JSONObject jsonObject) {
        if(!jsonObject.containsKey("orgId") || jsonObject.get("orgId") == null)
        {
            throw new RRException("orgId不能为空!");
        }
        if(!jsonObject.containsKey("amount") || jsonObject.get("amount") == null)
        {
            throw new RRException("amount不能为空!");
        }
        orgAcctService.intoCash(jsonObject);
        return ResponseJson.success();
    }
}
